package o;

import android.text.TextUtils;
import androidx.annotation.Nullable;
import com.huawei.updatesdk.service.otaupdate.UpdateStatusCode.DialogButton;
import java.util.ArrayList;

public final class anb {
    private static final ArrayList<e> ॱ = new ArrayList();

    static final class e {
        public final int ˋ;
        public final String ˎ;
        public final String ॱ;
    }

    public static boolean ˏ(@Nullable String str) {
        return "audio".equals(ᐝ(str));
    }

    public static boolean ˋ(@Nullable String str) {
        return "video".equals(ᐝ(str));
    }

    public static boolean ˊ(@Nullable String str) {
        return "text".equals(ᐝ(str));
    }

    @Nullable
    public static String ॱ(@Nullable String str) {
        String str2 = null;
        if (str == null) {
            return str2;
        }
        String ˎ = anr.ˎ(str.trim());
        if (ˎ.startsWith("avc1") || ˎ.startsWith("avc3")) {
            return "video/avc";
        }
        if (ˎ.startsWith("hev1") || ˎ.startsWith("hvc1")) {
            return "video/hevc";
        }
        if (ˎ.startsWith("vp9") || ˎ.startsWith("vp09")) {
            return "video/x-vnd.on2.vp9";
        }
        if (ˎ.startsWith("vp8") || ˎ.startsWith("vp08")) {
            return "video/x-vnd.on2.vp8";
        }
        if (ˎ.startsWith("mp4a")) {
            if (ˎ.startsWith("mp4a.")) {
                ˎ = ˎ.substring(5);
                if (ˎ.length() >= 2) {
                    try {
                        str2 = ॱ(Integer.parseInt(anr.ˏ(ˎ.substring(0, 2)), 16));
                    } catch (NumberFormatException e) {
                    }
                }
            }
            if (str2 == null) {
                return "audio/mp4a-latm";
            }
            return str2;
        } else if (ˎ.startsWith("ac-3") || ˎ.startsWith("dac3")) {
            return "audio/ac3";
        } else {
            if (ˎ.startsWith("ec-3") || ˎ.startsWith("dec3")) {
                return "audio/eac3";
            }
            if (ˎ.startsWith("ec+3")) {
                return "audio/eac3-joc";
            }
            if (ˎ.startsWith("dtsc") || ˎ.startsWith("dtse")) {
                return "audio/vnd.dts";
            }
            if (ˎ.startsWith("dtsh") || ˎ.startsWith("dtsl")) {
                return "audio/vnd.dts.hd";
            }
            if (ˎ.startsWith("opus")) {
                return "audio/opus";
            }
            if (ˎ.startsWith("vorbis")) {
                return "audio/vorbis";
            }
            if (ˎ.startsWith("flac")) {
                return "audio/flac";
            }
            return ॱॱ(ˎ);
        }
    }

    @Nullable
    public static String ॱ(int i) {
        switch (i) {
            case 32:
                return "video/mp4v-es";
            case 33:
                return "video/avc";
            case 35:
                return "video/hevc";
            case 64:
            case 102:
            case 103:
            case 104:
                return "audio/mp4a-latm";
            case 96:
            case 97:
            case 98:
            case 99:
            case DialogButton.CANCEL /*100*/:
            case DialogButton.CONFIRM /*101*/:
                return "video/mpeg2";
            case 105:
            case 107:
                return "audio/mpeg";
            case 106:
                return "video/mpeg";
            case 163:
                return "video/wvc1";
            case 165:
                return "audio/ac3";
            case 166:
                return "audio/eac3";
            case 169:
            case 172:
                return "audio/vnd.dts";
            case 170:
            case 171:
                return "audio/vnd.dts.hd";
            case 173:
                return "audio/opus";
            case 177:
                return "video/x-vnd.on2.vp9";
            default:
                return null;
        }
    }

    public static int ˎ(@Nullable String str) {
        if (TextUtils.isEmpty(str)) {
            return -1;
        }
        if (ˏ(str)) {
            return 1;
        }
        if (ˋ(str)) {
            return 2;
        }
        if (ˊ(str) || "application/cea-608".equals(str) || "application/cea-708".equals(str) || "application/x-mp4-cea-608".equals(str) || "application/x-subrip".equals(str) || "application/ttml+xml".equals(str) || "application/x-quicktime-tx3g".equals(str) || "application/x-mp4-vtt".equals(str) || "application/x-rawcc".equals(str) || "application/vobsub".equals(str) || "application/pgs".equals(str) || "application/dvbsubs".equals(str)) {
            return 3;
        }
        if ("application/id3".equals(str) || "application/x-emsg".equals(str) || "application/x-scte35".equals(str)) {
            return 4;
        }
        if ("application/x-camera-motion".equals(str)) {
            return 5;
        }
        return ʼ(str);
    }

    public static int ʻ(String str) {
        int i = -1;
        switch (str.hashCode()) {
            case -2123537834:
                if (str.equals("audio/eac3-joc")) {
                    i = 2;
                    break;
                }
                break;
            case -1095064472:
                if (str.equals("audio/vnd.dts")) {
                    i = 3;
                    break;
                }
                break;
            case 187078296:
                if (str.equals("audio/ac3")) {
                    i = 0;
                    break;
                }
                break;
            case 1504578661:
                if (str.equals("audio/eac3")) {
                    i = 1;
                    break;
                }
                break;
            case 1505942594:
                if (str.equals("audio/vnd.dts.hd")) {
                    i = 4;
                    break;
                }
                break;
            case 1556697186:
                if (str.equals("audio/true-hd")) {
                    i = 5;
                    break;
                }
                break;
        }
        switch (i) {
            case 0:
                return 5;
            case 1:
            case 2:
                return 6;
            case 3:
                return 7;
            case 4:
                return 8;
            case 5:
                return 14;
            default:
                return 0;
        }
    }

    @Nullable
    private static String ᐝ(@Nullable String str) {
        if (str == null) {
            return null;
        }
        int indexOf = str.indexOf(47);
        if (indexOf != -1) {
            return str.substring(0, indexOf);
        }
        throw new IllegalArgumentException("Invalid mime type: " + str);
    }

    @Nullable
    private static String ॱॱ(String str) {
        int size = ॱ.size();
        for (int i = 0; i < size; i++) {
            e eVar = (e) ॱ.get(i);
            if (str.startsWith(eVar.ॱ)) {
                return eVar.ˎ;
            }
        }
        return null;
    }

    private static int ʼ(String str) {
        int size = ॱ.size();
        for (int i = 0; i < size; i++) {
            e eVar = (e) ॱ.get(i);
            if (str.equals(eVar.ˎ)) {
                return eVar.ˋ;
            }
        }
        return -1;
    }
}
